import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class JDBCDelete {
    public static void main(String[] args) throws SQLException {
        DataSource dataSource = new MysqlDataSource();
        ((MysqlDataSource)dataSource).setUrl("jdbc:mysql://127.0.0.1:3306/java?characterEncoding=UTF-8&useSSL=false");
        ((MysqlDataSource)dataSource).setUser("root");
        ((MysqlDataSource)dataSource).setPassword("1234");


        Connection connection = dataSource.getConnection();

        String sql = "delete from students where name = '张三三'";
        PreparedStatement preparedStatement = connection.prepareStatement(sql);

        int n = preparedStatement.executeUpdate();
        System.out.println("n = "+ n);

        preparedStatement.close();
        connection.close();

    }
}
